/**
 * Created by CK on 2016/11/8.
 */
$(document).ready(function(){
    var appCode   = xhTool.getQuery('iAppCode');
    var classId   = xhTool.getQuery('sClassId');
    var stuId     = xhTool.getQuery('iStuId');
    var list      = $('#List');
    var startDom  = $('#List_Search_StartTime');
    var endDom    = $('#List_Search_EndTime');
    var startTime = xhTool.getQuery('iStartTime');
    var endTime   = xhTool.getQuery('iEndTime');
    if(!startTime){
        startDom.datebox('setValue', GetDateStr(-1));
        startTime = startDom.getElementValue();
    }
    else{
        startDom.datebox('setValue', startTime);
    }
    if(!endTime){
        endDom.datebox('setValue', GetDateStr(-1));
        endTime   = endDom.getElementValue();
    }
    else{
        endDom.datebox('setValue', endTime);
    }
    var queryParams = {
        iAppCode: appCode,
        sClassId: classId,
        iStuId: stuId,
        iStartTime: startTime,
        iEndTime: endTime
    };
    list.initDataGrid(baseUrl + 'Stats/getSingleStuPracticeData', {queryParams: queryParams});
    $('#bt_list_search').click(function(){
        startTime = startDom.getElementValue();
        endTime   = endDom.getElementValue();
        if(!startTime || !endTime){
            alert('时间不可为空！');
            return false;
        }
        queryParams.iStartTime = startTime;
        queryParams.iEndTime   = endTime;
        list.addDataGridParams(queryParams);
    });
    //DataGrid.onDblClickRow = function(rowIndex, rowData){
    //    window.top.xhTop.createNewTab('统计_作业详情_' + rowData.sTaskTitle,
    //        baseUrl + 'Stats/stuSingleTask?iAppCode=' + appCode + '&iSchoolId=' + schoolId
    //        + '&sClassId=' + classId + '&iStuId=' + stuId + '&sTaskId=' + rowData.sTaskId
    //    );
    //};
});
function GetDateStr(AddDayCount) {
    var dd = new Date();
    dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
    var y = dd.getFullYear();
    var m = dd.getMonth()+1;//获取当前月份的日期
    var d = dd.getDate();
    return y+"-"+m+"-"+d;
}